package fuckTest.thread;

public class 打印1a2b3c {

    static Boolean pNum = true;

    static class printNum implements Runnable {

        private int num = 0;

        @Override
        public void run() {
            for (int i = 0; i < 26; i++) {
                try {
                    if (pNum) {
                        System.out.print(num++);
                        pNum = false;
                        notifyAll();
                    } else {
                        wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    static class pringChar implements Runnable {

        private char str = 'A';

        @Override
        public void run() {
            for (int i = 0; i < 26; i++) {
                try {
                    if (!pNum) {
                        System.out.print(str++);
                        pNum = true;
                        notifyAll();
                    } else {
                        wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(new printNum());
        Thread t2 = new Thread(new pringChar());
        t1.start();
        t2.start();
    }


}
